package com.fuluwa.domain.usercenter.model.competence;

import java.util.List;

/**
 * Define the 4 competences,and their implementation.
 * @author yongxia
 * @Date Jul 13, 2013 11:22:58 PM
 */
public enum CompetenceType{
	GENERIC(new GenericCompetence()),PROFESSION(null),ORG_IMPACT(null),HAND_WORKING(null);
	private AbstractCompetence competence;
	

	private CompetenceType(AbstractCompetence competence) {
		this.competence = competence;
		if(competence!=null) {
			competence.setType(this);
		}
	}

	public AbstractCompetence getCompetence() {
		return competence;
	}
	
	public float compute(List<CompetenceSubDefine> subScores,LevelAdditionDefine levelAddtionDefine) {
		float ret=0;
		List<CompetenceSubDefine> subs= subScores;
		for (CompetenceSubDefine compSubDefineScore : subs) {
			ret+=compSubDefineScore.compute();
		}
		ret/=subs.size();
		
		ret*=(levelAddtionDefine.getAddtion()+1);
		
		return ret;
	}
	//TODO each type have one implement class.
}